import {Component, OnInit, ElementRef, ViewChild, Input, ViewEncapsulation} from '@angular/core';
import {Subject} from "rxjs";


@Component({
  selector: 'seed-view-video',
  templateUrl: 'view-video.component.html',
  styleUrls: ['view-video.component.scss'],
  encapsulation: ViewEncapsulation.None,
})
export class ViewVideoComponent implements OnInit {
  public _link: string;
  public _poster: string;

  @Input()
  get link() {
    return this._link;
  }

  set link(val: string) {
    this._link = val;
  }

  @Input()
  get poster() {
    return this._poster;
  }

  set poster(val: string) {
    this._poster = val;
  }

  @Input() modal;
  @Input() content;

  @ViewChild('player') player;
  private parentSubject: Subject<any> = new Subject<any>();

  constructor(public element: ElementRef) {
  }

  resize(event) {
    const widths = this.element.nativeElement.offsetWidth;
    const heights = this.element.nativeElement.offsetHeight;

    this.parentSubject.next({
      width: widths,
      height: heights,
    });

  }

  orientationChange(event) {
    window.setTimeout(() => {
      this.resize(event);
    }, 150);
  }

  dismiss() {
    this.modal.goBack();
  }


  ngOnInit() {

  }


}
